home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / lat1ibmp.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  5KB  |  180 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    latin1_ibmpc
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. static const char *translation_table[128] =
  25.   {
  26.     NULL,            /* \200 */
  27.     NULL,            /* \201 */
  28.     NULL,            /* \202 */
  29.     NULL,            /* \203 */
  30.     NULL,            /* \204 */
  31.     NULL,            /* \205 */
  32.     NULL,            /* \206 */
  33.     NULL,            /* \207 */
  34.     NULL,            /* \210 */
  35.     NULL,            /* \211 */
  36.     NULL,            /* \212 */
  37.     NULL,            /* \213 */
  38.     NULL,            /* \214 */
  39.     NULL,            /* \215 */
  40.     NULL,            /* \216 */
  41.     NULL,            /* \217 */
  42.     NULL,            /* \220 */
  43.     NULL,            /* \221 */
  44.     NULL,            /* \222 */
  45.     NULL,            /* \223 */
  46.     NULL,            /* \224 */
  47.     NULL,            /* \225 */
  48.     NULL,            /* \226 */
  49.     NULL,            /* \227 */
  50.     NULL,            /* \230 */
  51.     NULL,            /* \231 */
  52.     NULL,            /* \232 */
  53.     NULL,            /* \233 */
  54.     NULL,            /* \234 */
  55.     NULL,            /* \235 */
  56.     NULL,            /* \236 */
  57.     NULL,            /* \237 */
  58.  
  59.     "\377",            /* \240  \  */
  60.     "\255",            /* \241  !` */
  61.     "\233",            /* \242  \cent */
  62.     "\234",            /* \243  \pound */
  63.     NULL,            /* \244 */
  64.     "\235",            /* \245  \yen */
  65.     NULL,            /* \246 */
  66.     NULL,            /* \247 */
  67.     NULL,            /* \250 */
  68.     NULL,            /* \251 */
  69.     "\246",            /* \252  a_ */
  70.     "\256",            /* \253  `` */
  71.     "\252",            /* \254  \neg */
  72.     NULL,            /* \255 */
  73.     NULL,            /* \256 */
  74.     NULL,            /* \257 */
  75.     "\370",            /* \260  \deg */
  76.     "\361",            /* \261  +- */
  77.     "\375",            /* \262  ^2 */
  78.     NULL,            /* \263 */
  79.     NULL,            /* \264 */
  80.     "\346",            /* \265  \micro */
  81.     NULL,            /* \266 */
  82.     "\372",            /* \267  \cdot */
  83.     NULL,            /* \270 */
  84.     NULL,            /* \271 */
  85.     "\247",            /* \272  o_ */
  86.     "\257",            /* \273  '' */
  87.     "\254",            /* \274  1/4 */
  88.     "\253",            /* \275  1/2 */
  89.     NULL,            /* \276 */
  90.     "\250",            /* \277  ?' */
  91.     NULL,            /* \300 */
  92.     NULL,            /* \301 */
  93.     NULL,            /* \302 */
  94.     NULL,            /* \303 */
  95.     "\216",            /* \304  A" */
  96.     "\217",            /* \305  AA */
  97.     "\222",            /* \306  AE */
  98.     "\200",            /* \307  C, */
  99.     NULL,            /* \310 */
  100.     "\220",            /* \311  E' */
  101.     NULL,            /* \312 */
  102.     NULL,            /* \313 */
  103.     NULL,            /* \314 */
  104.     NULL,            /* \315 */
  105.     NULL,            /* \316 */
  106.     NULL,            /* \317 */
  107.     NULL,            /* \320 */
  108.     "\245",            /* \321  N~ */
  109.     NULL,            /* \322 */
  110.     NULL,            /* \323 */
  111.     NULL,            /* \324 */
  112.     NULL,            /* \324 */
  113.     "\231",            /* \326  O" */
  114.     "\366",            /* \327  \div */
  115.     NULL,            /* \330 */
  116.     NULL,            /* \331 */
  117.     NULL,            /* \332 */
  118.     NULL,            /* \333 */
  119.     "\232",            /* \334  U" */
  120.     NULL,            /* \335 */
  121.     NULL,            /* \336 */
  122.     "\341",            /* \337  \ss */
  123.     "\205",            /* \340  a` */
  124.     "\240",            /* \341  a' */
  125.     "\203",            /* \342  a^ */
  126.     NULL,            /* \343 */
  127.     "\204",            /* \344  a" */
  128.     "\206",            /* \345  aa */
  129.     "\221",            /* \346  ae */
  130.     "\207",            /* \347  c, */
  131.     "\212",            /* \350  e` */
  132.     "\202",            /* \351  e' */
  133.     "\210",            /* \352  e^ */
  134.     "\211",            /* \353  e" */
  135.     "\215",            /* \354  i` */
  136.     "\241",            /* \355  i' */
  137.     "\214",            /* \356  i^ */
  138.     "\213",            /* \357  i" */
  139.     NULL,            /* \360 */
  140.     "\244",            /* \361  n~ */
  141.     "\225",            /* \362  o` */
  142.     "\242",            /* \363  o' */
  143.     "\223",            /* \364  o^ */
  144.     NULL,            /* \365 */
  145.     "\224",            /* \366  o" */
  146.     NULL,            /* \367 */
  147.     NULL,            /* \370 */
  148.     "\227",            /* \371  u` */
  149.     "\243",            /* \372  u' */
  150.     "\226",            /* \373  u^ */
  151.     "\201",            /* \374  u" */
  152.     NULL,            /* \375 */
  153.     NULL,            /* \376 */
  154.     "\230",            /* \377  y" */
  155.   };
  156.  
  157. void
  158. STEP (FILE *input_file, FILE *output_file)
  159. {
  160.   int input_char;        /* current character */
  161.   const char *output_string;    /* translated characters */
  162.  
  163.   while (input_char = getc (input_file), input_char != EOF)
  164.     if ((input_char & 0377) < 0200)
  165.       if (input_char == '\n')
  166.     {
  167.       putc (0x0D, output_file);
  168.       putc (0x0A, output_file);
  169.     }
  170.       else
  171.     putc (input_char, output_file);
  172.     else
  173.       if (output_string = translation_table[input_char & 0177], output_string)
  174.     while (*output_string)
  175.       {
  176.         putc (*output_string, output_file);
  177.         output_string++;
  178.       }
  179. }
  180.